home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
ada
/
gwuada_9.zip
/
INT.H
< prev
next >
Wrap
C/C++ Source or Header
|
1992-10-05
|
14KB
|
389 lines
/*
* Copyright (C) 1985-1992 New York University
*
* This file is part of the Ada/Ed-C system. See the Ada/Ed README file for
* warranty (none) and distribution info and also the GNU General Public
* License for more details.
*/
/* +---------------------------------------------------+
| |
| I N T E R P M A I N |
| |
| (C Version) |
| |
| Adapted From Low Level SETL version written by |
| |
| Monte Zweben |
| Philippe Kruchten |
| Jean-Pierre Rosen |
| |
| Original High Level SETL version written by |
| |
| Robert B. K. Dewar |
| Clint Goss |
| Tracey M. Siesser |
| Bernard D. Banner |
| Stephen C. Bryant |
| Gerry Fisher |
| |
| C version written by |
| |
| Robert B. K. Dewar |
| |
+---------------------------------------------------+ */
#include <stdio.h>
/* This module contains constants used in all parts of the interpretor */
/*
* General use constants
* ---------------------
*/
#define VERSION "9-25-85" /* version identification */
#define NB_REGISTERS 6
#define ADA_MAX_REAL 8.507055E+37 /* maximum real with safety */
#ifndef TRUE
#define TRUE 1 /* boolean true = Ada true */
#endif
#ifndef FALSE
#define FALSE 0 /* boolean false = Ada false */
#endif
#define MIN_LONG ((long)0x80000000) /* minimum fixed value */
#define MAX_LONG ((long)0x7fffffff) /* maximum fixed value */
#define ENDLESS -1 /* value for endless delay */
#define NULL_INT ((int *)0) /* null pointer value */
/* Special task values, note that OWNER_WAITING must be less than NULL_TASK
* when two task numbers are compared. This is required for correct functioning
* of the tasking code.
*/
#define NULL_TASK -1 /* null task pointer value */
#define OWNER_WAITING -2 /* minimum fixed value */
/* Mask for stack access = MAX_TASKS - 1.
* Note that MAX_TASKS must be a power of two.
*/
#define TMASK 0177
/* Default Values */
#define SECURITY_LEVEL 50 /* free words in the stack before calls */
#define TASK_CODE_OFFSET 4 /* starting offset in code segment for task */
/* Size of long and float values in words (ints) */
#define WORDS_FLOAT (sizeof(float)/sizeof(int))
#define WORDS_LONG (sizeof(long)/sizeof(int))
#define WORDS_PTR (sizeof(int *)/sizeof(int))
/* WORDS_HDR is number of words in header of heap block */
#define WORDS_HDR (1 + WORDS_PTR)
/* Definition of a stack frame */
#define SF_PREVIOUS_SFP 0
#define SF_RETURN_CS 1
#define SF_RETURN_IP 2
/* Definition of exceptions */
#define CONSTRAINT_ERROR 1
#define NUMERIC_ERROR 1
#define PROGRAM_ERROR 3
#define STORAGE_ERROR 4
#define TASKING_ERROR 5
#define SYSTEM_ERROR 6
/* these come from predef and not be defined here */
#define STATUS_ERROR 7
#define MODE_ERROR 8
#define NAME_ERROR 9
#define USE_ERROR 10
#define DEVICE_ERROR 11
#define END_ERROR 12
#define DATA_ERROR 13
#define LAYOUT_ERROR 14
#define TIME_ERROR 15
/* Attributes */
/* Those attributes marked "static" are treated by the front end and do not
* appear as arguments to the attribute instruction. Note that POS and VAL
* are not static, but do not appear as attribute instruction arguments
Static:
A_AFT ATTR_BASE ATTR_DELTA ATTR_DIGITS ATTR_EMAX ATTR_EPSILON ATTR_FIRST_BIT
ATTR_MACHINE_EMAX ATTR_MACHINE_EMIN ATTR_MACHINE_MANTISSA
ATTR_MACHINE_OVERFLOWS ATTR_MACHINE_RADIX ATTR_MACHINE_ROUNDS
ATTR_POS -- not static but generates nothing
ATTR_SAFE_EMAX ATTR_SAFE_LARGE ATTR_SAFE_SMALL
ATTR_SMALL ATTR_STORAGE_SIZE(?)
ATTR_VAL --not static but generate a qual_range
*/
#include "attr.h"
#include "ops.h"
/* General Addressing Macros */
/*
* LONG(ptr) Pointer regarded as pointer to long value
* ADDR(ds,off) Get address from data seg offset values
* ADDRL(ds,off) Get address of long from data seg offset values
* POP(val) Pop int val off stack
* POPF(fval) Pop float fval off stack
* POPL(lval) Pop long lvall off stack
* POPP(lval) Pop pointer from stack
* POP_ADDR(bs,of) Pop base/offset address from stack
* POP_PTR(ptr) Pop pointer from stack
* PUSH(val) Push int val onto stack
* PUSHF(fval) Push float fval onto stack
* PUSHL(lval) Push long lval onto stack (also used for fixed)
* PUSHP(lval) Push pointer onto stack
* PUSH_ADDR(bs,of) Push address onto stack
* TOS Reference top of stack as int
* TOSF Reference top of stack as float
* TOSL Reference top of stack as long
* TOSM(n) Reference n'th item from top (TOS = TOSM(0))
* BLOCK_FRAME Pointer to the current block frame
* STACK_FRAME(dsp) Access an element from the current stack frame
*/
#define LONG(ptr) ((long *)(ptr))
#define ADDR(ds,off) (data_segments[ds] + off)
#define ADDRL(ds,off) (LONG(data_segments[ds] + off))
#define POP(val) val=cur_stack[cur_stackptr--]
#define POPF(fval) fval = TOSF,cur_stackptr -= WORDS_FLOAT
#define POPL(lval) lval = TOSL,cur_stackptr -= WORDS_LONG
#define POPP(lval) POPL((long)lval)
#define POP_ADDR(bs,of) POP(of),POP(bs)
#define POP_PTR(pt) pt=ADDR(TOSM(1),TOS),cur_stackptr -= 2
#define PUSH(val) cur_stack[++cur_stackptr] = val
#define PUSHF(fval) cur_stackptr+=WORDS_FLOAT,TOSF=fval
#define PUSHL(lval) cur_stackptr+=WORDS_FLOAT,TOSL=lval
#define PUSHP(lval) PUSHL((long)lval)
#define PUSH_ADDR(bs,of) PUSH(bs),PUSH(of)
#define TOS (cur_stack[cur_stackptr])
#define TOSF *((float *)(cur_stack+cur_stackptr+1-WORDS_FLOAT))
#define TOSL *(LONG(cur_stack+cur_stackptr+1-WORDS_LONG))
#define TOSML(n) *(LONG(cur_stack+cur_stackptr+1-((n)+1)*WORDS_LONG))
#define TOSM(n) (cur_stack[cur_stackptr-(n)])
#define BLOCK_FRAME ((struct bf *)(cur_stack+bfp))
#define ARB_BLOCK_FRAME(t,b) ((struct bf *)((STACK(t))+(b)))
#define STACK_FRAME(dsp) cur_stack[sfp+dsp]
/* Macros for accessing fields of block frame */
#define BF_PREVIOUS_BFP(t,b) (ARB_BLOCK_FRAME(t,b))->bf_previous_bfp
#define BF_DATA_LINK(t,b) (ARB_BLOCK_FRAME(t,b))->bf_data_link
#define BF_TASKS_DECLARED(t,b) (ARB_BLOCK_FRAME(t,b))->bf_tasks_declared
#define BF_SUBTASKS(t,b) (ARB_BLOCK_FRAME(t,b))->bf_subtasks
#define BF_HANDLER(t,b) (ARB_BLOCK_FRAME(t,b))->bf_handler
#define BF_NUM_NOTERM(t,b) (ARB_BLOCK_FRAME(t,b))->bf_num_noterm
#define BF_NUM_DEPS(t,b) (ARB_BLOCK_FRAME(t,b))->bf_num_deps
#define MY_PREVIOUS_BFP (BLOCK_FRAME)->bf_previous_bfp
#define MY_DATA_LINK (BLOCK_FRAME)->bf_data_link
#define MY_TASKS_DECLARED (BLOCK_FRAME)->bf_tasks_declared
#define MY_SUBTASKS (BLOCK_FRAME)->bf_subtasks
#define MY_HANDLER (BLOCK_FRAME)->bf_handler
#define MY_BF_NUM_NOTERM (BLOCK_FRAME)->bf_num_noterm
#define MY_BF_NUM_DEPS (BLOCK_FRAME)->bf_num_deps
/* Utility Macros */
#define ABS(v) ((v) >= 0 ? (v) : -(v))
#define BOOL(v) ((v) % 2)
#define MAX(a,b) (((a) >= (b)) ? (a) : (b))
#define MIN(a,b) (((a) <= (b)) ? (a) : (b))
#define SIGN(a) (((a) > 0) - ((a) < 0))
/* Block Frame */
struct bf {
int bf_previous_bfp; /* offset to previous block frame */
int *bf_data_link; /* head of chain of data blocks */
int *bf_tasks_declared; /* head of chain of created tasks */
int bf_num_noterm; /* number of non terminated */
int bf_num_deps; /* number of non terminated */
int bf_subtasks; /* head of chain of dependent tasks */
int bf_handler; /* IP of exception handler */
};
/** NEW TYPES **/
/* Item Type for Multi-Queues */
struct rts_item {
int mult, save_mult; /* multiplicity count */
int parent; /* parent tcb index */
int *tcbs; /* array of tcb nums of new tasks */
int type; /* action - create or activate */
int prio; /* priority